/******************************************************************************
*
* This file is part of FreeTrack (http://code.google.com/p/qtfreetrack).
* BY Willy Gardiol (willy@gardiol.org)
*
* FreeTrack is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FreeTrack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar.  If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/

#ifndef MOBILEPUSHBUTTOM_H
#define MOBILEPUSHBUTTOM_H

#include <QtGui>

enum FTPB_state { pressed, not_pressed };

class FTPushButton : public QWidget
{
    Q_OBJECT
public:
    explicit FTPushButton(QWidget *parent = 0);
    explicit FTPushButton(const QIcon&, const QSize&, QWidget *parent = 0);
    explicit FTPushButton(const QString&, QWidget *parent = 0);

    void mousePressEvent ( QMouseEvent * event );
    void mouseReleaseEvent ( QMouseEvent * event );
    void paintEvent ( QPaintEvent * event );

    QSize sizeHint() const;
    QSize minimumSizeHint() const;

    void setIcon( const QIcon&, const QSize& );
    void setText( const QString& );

    void setCheckable( bool );
    bool isCheckable() const;
    void setChecked( bool );
    bool isChecked() const;

    void setBackground( const QBrush& def, const QBrush& pres = QBrush(), const QBrush& che = QBrush() );
    void setForeground( const QPen& );

signals:
    void clicked(bool checked = false);

public slots:
    void click();

private:
    bool checked;
    bool is_checkable;
    bool use_icon;
    bool use_text;
    QIcon icon;
    QSize button_size;
    QSize icon_size;
    QString text;
    QPen text_pen;
    QPen border_pen;
    QBrush background;
    QBrush checked_background;
    QBrush pressed_background;

    FTPB_state state;
    void initialize();

};

#endif // MOBILEPUSHBUTTOM_H
